package besteAukera;

import java.awt.Color;
import java.awt.Graphics;
import java.util.Vector;

public class NotFisikoa extends AteLogikoak {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Color kolorea;
	private Vector<Hanka> hankaBektorea = new Vector<Hanka>();
	private Vector<Hanka> sarreraBektorea = new Vector<Hanka>();
	private Hanka s1, i1;

	public NotFisikoa(int x1, int y1, int hankaKop, int sarKop,String motaFis, Color kolorea) {
		super(x1, y1, hankaKop, sarKop,motaFis, kolorea);
		// TODO Auto-generated constructor stub
		if (motaFisikoa.compareTo("posNegH") == 0) {
			s1 = new Hanka(x, y + 12, "positiboa", "s", 0, this, "h", "ez",false);
			i1 = new Hanka(x + 60, y + 12, "negatiboa", "i", 1, this, "h", "ez",false);
		} else if (motaFisikoa.compareTo("negPosH") == 0) {
			s1 = new Hanka(x, y + 12, "negatiboa", "s", 0, this, "h", "ez",false);
			i1 = new Hanka(x + 60, y + 12, "positiboa", "i", 1, this, "h", "ez",false);
		}
		else if (motaFisikoa.compareTo("negPosB") == 0) {
			s1 = new Hanka(x+30, y - 18, "negatiboa", "s", 0, this, "b", "ez",false);
			i1 = new Hanka(x + 30, y + 42, "positiboa", "i", 1, this, "b", "ez",false);		}
		else if (motaFisikoa.compareTo("posNegB") == 0) {
			s1 = new Hanka(x+30, y  -18, "positiboa", "s", 0, this, "b", "ez",false);
			i1 = new Hanka(x + 30, y + 42, "negatiboa", "i", 1, this, "b", "ez",false);
		}
		lotList[0] = s1;
		lotList[1] = i1;
	}

	public void marraztu(Graphics g) {
		if (getAukeratua() == true) {
			kolorea = Color.GRAY;
		} else {
			kolorea = Color.black;
		}
		g.setColor(kolorea);
		if(motaFisikoa.compareTo("posNegH")==0||motaFisikoa.compareTo("negPosH")==0){
		g.drawLine(x + 20, y + 22, x + 20, y + 2);
		g.drawLine(x + 20, y + 22, x + 40, y + 12);
		g.drawLine(x + 20, y + 2, x + 40, y + 12);
		s1.marraztu(g);
		i1.marraztu(g);
		}
		else if(motaFisikoa.compareTo("posNegB")==0||motaFisikoa.compareTo("negPosB")==0){
			g.drawLine(x + 20, y + 2, x + 40, y + 2);
			g.drawLine(x + 20, y + 2, x + 30, y + 22);
			g.drawLine(x + 40, y + 2, x + 30, y + 22);
			s1.marraztu(g);
			i1.marraztu(g);
			}
	}

	public boolean barruanDago(int x, int y) {
		if ((x > this.x+20) && (x < (this.x + 40)) && (y > this.y+2)
				&& (y < (this.y + 22))) {
			return true;
		}
		return false;
	}

	@Override
	public void funtzioLogikoa(Integer... values) {

		// TODO Auto-generated method stub
		lotList[1].getIrteera().setBalioa(lotList[0].getSarrera().getBalioa());

	}

	@Override
	public Vector<Hanka> getHankak() {
		// TODO Auto-generated method stub
		hankaBektorea = new Vector<Hanka>();
		hankaBektorea.addElement(s1);
		hankaBektorea.addElement(i1);
		return hankaBektorea;
	}

	@Override
	public Vector<Hanka> getSarreraHankak() {
		sarreraBektorea = new Vector<Hanka>();
		sarreraBektorea.addElement(s1);
		sarreraBektorea.addElement(i1);
		return sarreraBektorea;
	}
}